using SqlSugar;
using Vin.Extension.Framework.Quartz.Entities;
using Vin.Extension.Framework.Repository;

namespace Vin.Extension.Framework.Quartz.Repository;

public class SysJobGroupRepository : VinFrameworkBaseRecordRepository<SysJobGroup>
{
    public async Task<SysJobGroup> GetOrCreateByNameAsync(string name)
    {
        var whereExpression = Expressionable.Create<SysJobGroup>().And(m => m.Name == name);
        var model = await GetFirstAsync(whereExpression.ToExpression());
        return model != null ? model : (await SaveOrUpdateAsync(new SysJobGroup { Name = name }))!;
    }
}